package com.example.shop_2212.room

import android.app.Application
import androidx.room.Room

/**
 * 数据库工具类
 */
class AppDBUtils {
    companion object{
        private lateinit var appDataBase: AppDataBase
        //初始化数据库
        fun init(application: Application){
            appDataBase = Room.databaseBuilder(application,AppDataBase::class.java,"2212a.db")
                .allowMainThreadQueries()
                .build()
        }
        //对外暴露数据库    注意起名！！！
        fun getDB() = appDataBase

        fun getUDao() = appDataBase.getUserDao()//直接暴露userDao  注意，当新增一个实体类时，需要增加一个方法来暴露对应的dao

    }
}